package com.abhinav.jaxb;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;

import com.abhinav.jaxb.model.Address;
import com.abhinav.jaxb.model.CustomerJaxb;

public class MapDemo {
	public static void main(String[] args) throws JAXBException {
		JAXBContext jc = JAXBContext.newInstance(CustomerJaxb.class);

		Address billingAddress = new Address();
		//billingAddress.setStreet("1 A Street");

		Address shippingAddress = new Address();
		//shippingAddress.setStreet("2 B Road");

		CustomerJaxb customer = new CustomerJaxb();
		customer.getAddressMap().put("billing", billingAddress);
		customer.getAddressMap().put("shipping", shippingAddress);
		
		Marshaller marshaller = jc.createMarshaller();
		marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
		marshaller.marshal(customer, System.out);
	}

}
